﻿using System;

using System.Collections.Generic;
using System.Text;

namespace Win32
{
    public static class Win32Helper
    {
        public static void RunAppAtTime(string applicationEvent, DateTime startTime)
        {
            long fileTimeUTC = startTime.ToFileTime();
            long fileTimeLocal = 0;
            SystemTime systemStartTime = new SystemTime();
            CoreDLL.FileTimeToLocalFileTime(ref fileTimeUTC, ref fileTimeLocal);
            CoreDLL.FileTimeToSystemTime(ref fileTimeLocal, systemStartTime);
            CoreDLL.CeRunAppAtTime(applicationEvent, systemStartTime);

        }

        public static void RunAppAtTime(string applicationEvent, TimeSpan timeDisplacement)
        {
            DateTime targetTime = DateTime.Now + timeDisplacement;
            RunAppAtTime(applicationEvent, targetTime);
        }
    }
}
